home *** CD-ROM | disk | FTP | other *** search
/ LSD Docs / LSD Docs.iso / FILEZ / lsd20.dms / lsd20.adf / Imploder4.doc.pp / Imploder4.doc
Text File  |  1990-09-07  |  41KB  |  917 lines

  1.                 IMPLODER IV
  2.           COMPLETE MANUAL ETC, ALL IN ONE FILE!
  3.  
  4. Brought to you by LSD!
  5.  
  6.  
  7. How to operate the Imploder should be fairly obvious to the average Amiga
  8. user. So I'll try to highlight only those aspects of the user interface
  9. that aren't immediately obvious, and of course this document will explain
  10. how certain selections influence the processing behaviour.
  11.  
  12.  
  13. ------------------
  14. The User Interface
  15. ------------------
  16.  
  17. ** Configuring the Imploder **
  18.  
  19. When you run the Imploder, either from the CLI or WorkBench, you'll notice
  20. the music and NTSC size screen. This setup is configurable by way of
  21. commandline switches or tooltypes. Note that, under Kick 1.3 or less, when
  22. one sets a tooltype using the WorkBench's info option, the appended "=" is
  23. required for proper recognition.
  24. The default setting is enabled music without modifications to the filter or
  25. NTSC/PAL mode. However, you can disable the music using the "NOMUSIC"
  26. commandline switch, or the "NOMUSIC=" tooltype. The lowpass filter can be
  27. disabled for less muffled sound by specifying "NOFILTER/NOFILTER=".
  28. To people with PAL Amigas, the shrunken NTSC screen might look ugly, however
  29. if there is a fat Agnus chip in your machine, it can be toggled from a 50Hz
  30. to 60Hz display refresh rate. Setting "NTSC/NTSC=" will cause the Imploder to
  31. do this whenever its screen gets upfront.
  32.  
  33. In addition to this, there's the SHORTROOT configuration switch. This
  34. option is related to using the library. See the "library" document for
  35. further information on this.
  36.  
  37.  
  38. ** The File Requester **
  39.  
  40. Whenever there exists the need to specify a filename, a directory window will
  41. appear in front of the message window. Only a few of its options need
  42. clarification:
  43. -Switching on the ID toggle gadget causes the directory window to display
  44.  the type ID's of all files. This is useful, for example, to check if files
  45.  have already been imploded. This option will increase the time needed to
  46.  access a directory though.
  47. -Clicking on the proportional scroll gadget on the left will cause the list
  48.  of filenames to be sorted.
  49. -Switching off the .INFO toggle gadget causes the directory window not to
  50.  display the *.info files used by the WorkBench's icon system. 
  51. -Selecting a file is done by placing the mouse pointer on top of its name and
  52.  clicking the left mouse button. In addition to the normal ways of confirming
  53.  your selection, you can double-click on a filename.
  54. -Next to the immediately obvious ways of scrolling through a long directory,
  55.  one can place the pointer within the filename window, press the left button,
  56.  and while holding it down move the mouse above or below the filename window,
  57.  try it; it works great once you get used to it.
  58. -One does not have to wait for the entire directory to load before selecting
  59.  a file or entering a sub directory.
  60.  
  61.  
  62. ** Keyboard Equivalents **
  63.  
  64. Many functions selectable by mouse also react to keys. The menu options have
  65. the usual right-amiga+key shortcuts. In addition to this;
  66. - Hitting any key removes the about requester displayed during startup.
  67. - Use the escape key to exit the Imploder.
  68. - The "S" key starts processing.
  69. - When the merge/compression parameter window is present, you can select
  70.   the compression mode using numeric keys, and increase/decrease the merge
  71.   threshold using the "+" and "-" keys. You can cancel using ESC and proceed
  72.   by hitting RETURN.
  73. - The deplode query requester reacts to the "Y" and "N" keys.
  74.  
  75.  
  76. ** Loading / Saving **
  77.  
  78. When you have specified a file for the Imploder to load, processing will
  79. commence (detailed below), and once finished the file requester pops up
  80. to query you for the destination.
  81.  
  82. The source and destination paths are maintained in a special way that
  83. minimizes the chance of the destination not being what one wants. You
  84. could e.g. implode files from one directory and store them in another,
  85. or overwrite them in the source directory.
  86. In the first case it would be annoying if the destination directory defaults
  87. back to the source; you'd have to change it every time you want to write an
  88. imploded file. In the latter case, it'd be annoying to change to a different
  89. source directory and find out that the destination still points somewhere
  90. else.
  91.  
  92. So the logic the Imploder uses is as follows; if you change to a different
  93. source directory, the destination directory will follow the source directory
  94. only if the destination is equal to the source.
  95.  
  96.  
  97. ** Batch Mode **
  98.  
  99. The Imploder can compress a series of executables by allowing you to specify
  100. multiple files by way of ?,#,* wildcards. All non-imploded executables
  101. matching the pattern will be processed. After entering the wildcards, the
  102. "merge and compression" parameter window will appear. The options present
  103. there will be explained below. The important thing to note here is that
  104. these selections will be global to all files processed during batch mode.
  105. Next, you'll be asked to specify a destination directory. This is were all
  106. batched executables will be saved after implosion.
  107.  
  108.  
  109. ----------
  110. Processing
  111. ----------
  112.  
  113. Now you're familiar with the user interface, let me get on with explaining
  114. how the Imploder processes programs. The implosion processing sequence
  115. consists of four steps;
  116. -Loading & Format Verification.
  117. -Hunk Merging & Reloc Table Cleanup.
  118. -Implosion.
  119. -Decompression code installation, Overlay table adjustment and Saving.
  120.  
  121.  
  122. ** The Loader **
  123.  
  124. The loader reads the selected file. During this process, the executable
  125. file is analyzed. Format defects cause the loader to either report an
  126. error, and abort processing, or to give a warning while ignoring or
  127. repairing the defect.
  128.  
  129. After having loaded a file, the "merge and compression" parameter window
  130. will appear. You can click the topright icon to collapse this window and
  131. review the status information produced by the loader.
  132.  
  133.  
  134. ** The Merger **
  135.  
  136. The merger is disabled by default. Most executables produced by modern
  137. compilers/linkers don't require this option, so if you're impatient
  138. you can skip to the next section.
  139.  
  140. If selected, the merger will try to coalesce the hunks in a program to hunks
  141. of upto the merge threshold in size. If used in a constrained manner, this
  142. will reduce the size of the program, and the chance of memory fragmentation.
  143. If you specify a large merge threshold however, the resulting file will need
  144. large contiguous regions of memory in order to load, thus reducing the chance
  145. of it being able to be loaded into a fragmented system.
  146.  
  147. Merging an executable file might break it. This is because certain programs
  148. make assumptions about the format of their segment list. The most notable
  149. members of this group are BCPL programs and a few libraries and devices.
  150. Hunk merging is therefore automatically disallowed for these. Still, some
  151. other programs, especially selfdetaching programs might dislike being merged.
  152.  
  153. Regardless of whether a program has been merged or not, a reloc table
  154. cleanup routine is executed upon the file. This deletes empty reloc tables,
  155. coalesces matching reloc tables, and finally sorts the relocation offsets.
  156. This is of no consequence to how the program will look after it has been
  157. decompressed and relocated.
  158.  
  159.  
  160. ** Compression **
  161.  
  162. The compression algorithm can operate either in turbo mode or in normal mode.
  163. The normal mode requires no additional memory, whereas the turbo mode needs
  164. some 300K of additional hashing buffers. The turbo mode kicks-in automatically
  165. whenever the required amount of additional memory can be allocated. It is
  166. about ten to twenty times faster than the normal implosion mode.
  167. Note that the parameter window will report whether or not the current memory
  168. configuration allows the turbo to be enabled or not. You might try to free a
  169. few resources in order to make the target. Whenever you select a compression
  170. mode (gadgets 0-8), the turbo capability will be reevaluated.
  171.  
  172. Various compression modes can be specified. These modes vary from zero
  173. (range  = 128 bytes) to eight (range = 18K). The range related to each
  174. compression mode determines the maximum distance searched while looking for
  175. redundant data. The higher compression modes therefore have a better chance of
  176. compressing data.
  177.  
  178. The time required to compress a program increases proportionally to the
  179. maximum distance in case of non-turbo operation. The processing speed during
  180. turbo operation however, is only slightly affected by varying the compression
  181. mode.
  182.  
  183. So it only makes sense to fiddle with the compression mode if you don't have
  184. enough memory to have the Imploder run in turbo mode, and therefore want
  185. to speed things up (at the expense of a the compression efficiency).
  186.  
  187. For all other instances it suffices to leave the compression mode at its
  188. maximum value (eight); for small executables the mode will automatically
  189. be scaled down to what the Imploder thinks is probably the most efficient
  190. one for the file at hand.
  191.  
  192. During compression, the level meters to the right will display various
  193. relevant parameters. Going from left to right these are:
  194.  
  195. 1. Percentage of program data still to be compressed.
  196. 2. New size of executable in % of the former size. Reevaluated continuously.
  197. 3. Skip. If a large chunk of non-compressable dat is encountered within
  198.    a program, its level will start to rise. When it hits the top, the
  199.    encoding limit has been exceeded. This is a rare occurance.
  200. 4. Length. Gives a measure of the redundancy of the data currently being
  201.    processed. High levels indicate good compression.
  202. 5. Distance. Gives a measure of the non-locality of current redundancy.
  203.  
  204.  
  205. ** Decompression Code Installation **
  206.  
  207. All imploded executables require some additional memory in order to be
  208. able to decompress. The additional amount of memory required is about 50%
  209. of the original program size plus a constant amount of buffer space depending
  210. on the compression mode, and never larger than 20K.
  211. After decompression this memory is freed without causing memory fragmentation.
  212. Furthermore, the normal distribution of program-data across hunks is retained.
  213. This allows for the loading of imploded files into fragmented memory, and
  214. the proper distribution of hunks across chip and fast memory.
  215.  
  216. The Imploder is able to install 3 different decompression algorithms into
  217. imploded executables;
  218. Library, Normal and Overlayed.
  219.  
  220.  
  221. LIBRARY IMPLODED files are the default, they are generated when;
  222. -The "Compress" gadget is enabled.
  223. -The "Library" gadget is enabled.
  224. -The processed executable isn't overlayed.
  225.  
  226. To be able to use library Imploded files, copy the explode.library to your
  227. LIBS: directory. When you run a library imploded program, the decompression
  228. code in this library will be called. The library code is fast and removes
  229. the need of appending decompression code to every imploded file.
  230.  
  231. The library has several special useful properties discussed in the "Library"
  232. document, but for simple use it suffices to make sure the library is in LIBS:.
  233.  
  234. Pure programs may be library imploded.
  235.  
  236.  
  237. NORMAL IMPLODED files are generated when;
  238. -The "Compress" gadget is enabled.
  239. -The "Library" gadget is disabled (this is NOT the default).
  240. -The program being processed isn't overlayed.
  241.  
  242. Normal imploded files have decompression code appended to them. A normal
  243. imploded program will run just like the original, and is independent; in
  244. contrast with library imploded files, normal imploded files don't require
  245. libraries or other special files to be present in your system.
  246.  
  247. Disadvantages of normal Imploded files are that they are a couple of hundred
  248. bytes larger than library Imploded files, and their decompression speed is
  249. significantly slower. This is due to need for space optimizations in the
  250. decompression code.
  251.  
  252. Once you normal-implode a pure program it's no longer pure.
  253.  
  254.  
  255. OVERLAYED IMPLODED files are generated when;
  256. -The "Compress" gadget is enabled.
  257. -the processed executable is overlayed.
  258.  
  259. Overlayed programs are executables with additional appended hunks that are
  260. loaded during runtime. The Imploder will automatically recognize whether a
  261. program is overlayed.
  262.  
  263. Overlayed files are rather loosely defined; basically the program is passed
  264. a bit of information that allows it to get at the appended hunks, but the
  265. means of doing so is left up to the programmer, though there is a standard
  266. technique specified by CBM which is used by the majority of overlayed
  267. executables.
  268.  
  269. Because the Imploder decreases the size of the file, the offset of the
  270. overlay data also changes, and this must be corrected for. The Imploder
  271. knows how to do this for the standard overlay format. You'll be notified
  272. when the format isn't as the Imploder expects.
  273.  
  274. Thus imploding overlayed files is not something which is guaranteed to
  275. succeed, so take heed; you should only implode overlayed files when you
  276. know what you are doing, and are willing to verify the results.
  277.  
  278.  
  279. ---------
  280. Deplosion
  281. ---------
  282.  
  283. If you select an already imploded executable for processing (the ID gadget
  284. in the directory window allows you to see if files have already been imploded,
  285. at the cost of slower listing), you will be asked if you want to deplode it.
  286. If you confirm this query, the executable will be restored to a normal
  287. non-imploded format. Note that this format isn't necessarily bitwise
  288. identical to the original; the reloc tables are sorted, and you might
  289. have applied hunk merging (which is irreversible). Also, any symbol or
  290. debug hunks present in the original will have been stripped.
  291. Still, if you run the program, things will look the same to it, and
  292. this is ofcourse what counts.
  293.  
  294. Note that there is a CLI based "Deplode" command available in the Tools
  295. directory which does basically the same thing. This is purely a matter of
  296. convenience ment for people that think of the CLI as convenient.
  297.  
  298.  
  299.  
  300.  
  301. Changes V3.0 -> V4.0
  302. --------------------
  303.  
  304.  
  305. Major:
  306.  
  307. - Finally a complete and up-to-date well documented release with all
  308.   of the support utilities.
  309.  
  310. - Basic support for batchmode processing.
  311.  
  312. - Radical new music composition by Paul van der Valk.
  313.  
  314. - Erwin Zwart has completely redesigned the graphics to conform to the
  315.   2.0 look. Aesthetics and functionality have improved significantly.
  316.  
  317. - Defaults to support for a "safe library root". This is larger startup code
  318.   for library imploded files that warns when no library is present. You can
  319.   override this setting.
  320.  
  321. - The "Protect" option has been discontinued. See the "philosophy" document
  322.   for the rationale on this.
  323.  
  324. - Mouse hater support by way of a CLI based Deplode command, and keyboard
  325.   equivalents throughout.
  326.  
  327.  
  328.  
  329. Minor:
  330.  
  331. - Support for "pure-imploded" files removed; If you know how to make a
  332.   program resident, you know how to use the library.
  333.  
  334. - The "Library" gadget now defaults to on. 
  335.  
  336. - The "Merge" gadget now defaults to off. Improved compilers/linkers
  337.   plus the much more frequent appearance of selfdetaching programs have
  338.   made this option less important and more dangerous respectively.
  339.  
  340. - Added tooltypes and commandline switches for specifying the setup
  341.   options.
  342.  
  343. - The copperlist has been tuned down a bit, and the screen is now
  344.   dragable.
  345.  
  346. - The explode.library has been enhanced/sped up a bit.
  347.  
  348. - Removed bug that caused Intuition to read from location zero. This would
  349.   occasionally crash the machine when location zero was nonzero.
  350.   This bug was already removed in V3.1 (thanks to Arnout).
  351.  
  352. - All stuff has been enforced and mungwalled so now we've even better
  353.   confirmation that no serious bugs are present.
  354.  
  355. - Improved overlay file recognition. No longer expects overlayed files to
  356.   have additional space in the hunk table. Searches for the magic longword.
  357.  
  358. - Decodes ARP resident program tags. Warns against stack gobblers.
  359.  
  360. - Data hunk ID now preserved upon deplosion. Inconsequential, yet neater.
  361.   Very stringent format checks in the old deplosion routine barf on the
  362.   extra bit required for this, but the old explode library doesn't mind,
  363.   so in that sense it is backwards compatible.
  364.  
  365. - Lots of other small changes.
  366.  
  367.  
  368.  
  369.  
  370. ** Features **
  371.  
  372. Library-imploding files is preferable, not only because the result is
  373. smaller, but also because the library is faster, and able to patch the
  374. AmigaDOS executable file loader (LoadSeg), thus decompressing ANY type
  375. of load file as soon as it is loaded into memory, e.g. fonts, devices,
  376. libraries, etc.
  377.  
  378. If you only library-implode program files, the library will be loaded
  379. when you run a library imploded program for the first time. However if
  380. you wish to implode non-program executables, you'll have to make sure
  381. the library is already resident because these won't load properly until
  382. LoadSeg has been wedged. If you're not yet using the 2.0 OS, there is a
  383. slight complication explained in the section at the end of this document.
  384.  
  385. To make sure the library is resident, we've provided a small program that
  386. can be run at the head of your startup sequence. It's called "ExpLoad"
  387. and resides in the tools subdirectory. All it does is open the explode 
  388. library. Once this is done, the library hooks itself into DOS and remains
  389. resident, even when a system flush occurs.
  390.  
  391. Note that it suffices to run a library imploded program to make the
  392. library resident, but this is less visible so you might forget about it
  393. when you modify your startup-sequence later on.
  394.  
  395. Once you've made sure the library is resident, you may merrily go around
  396. your system and library-implode libraries, devices, fonts and even keymaps!
  397.  
  398. By default the Imploder appends a foolproof piece of startup code to
  399. library imploded files. This checks whether the library is present.
  400. If not it will print an error. If started from the WorkBench a tiny
  401. window will be opened to display the error message.
  402.  
  403. However this error checking takes up a bit of space, and is redundant
  404. when you make sure the library is resident. For this reason you can
  405. specify the SHORTROOT tooltype/switch. When set, the Imploder will
  406. append only short startup code to library imploded files. This saves
  407. about 250 bytes for every executable.
  408.  
  409. If library imploded programs with a short root do not find the explode
  410. library they will keep on trying to open it until they succeed. These
  411. programs will therefore hang until the LIBS: directory contains the
  412. library.
  413.  
  414. Still, using the SHORTROOT switch has its advantages. The reason it is not
  415. enabled by default is to make sure that people have read this document
  416. first.
  417.  
  418.  
  419. ** Pre-2.0 problems **
  420.  
  421. If you are NOT using 2.0 or some newer OS, there are a few additional
  422. problems related to BCPL braindeadness, so if you're still running 1.3 or
  423. less, READ THIS!
  424.  
  425. Under a pre 2.0 OS, if you run a library imploded program generated with
  426. the SHORTROOT option from the WorkBench, while the library hasn't been made
  427. resident yet, the system will guru. This is a problem caused by the OS.
  428. The default library startup code checks for this condition, and will exit
  429. cleanly after reporting an error.
  430.  
  431. So under 1.3 or less it is advisable to make the explode.library resident
  432. before the WorkBench is active, e.g. early in your startup sequence, even
  433. when you're using library imploded non-program executables;
  434. The first invocation of a library imploded program might happen from the
  435. WorkBench.
  436.  
  437. In addition to this it is best not to library implode handlers under pre
  438. 2.0. See the Techno document for an in depth explanation of these issues.
  439.  
  440.  
  441. ** Conclusion **
  442.  
  443. Library implosion limits the possibility of passing on one's executables
  444. to other people/systems who/that do not have the explode.library installed.
  445. I think this doesn't really matter because I strongly believe people
  446. should be left the option of deciding in what way, if at all, they are
  447. going to compress/install executables. (See the "Philosophy" document
  448. for a more extensive discussion of this issue).
  449.  
  450. Evidently, using library imploded files is the most transparent to the
  451. system. We personally recommend using mostly library implosion, and only
  452. in special cases normal implosion, or overlay implosion for the odd
  453. overlayed file one might encounter.
  454.  
  455.  
  456.  
  457.  
  458. This doc may sound slightly grumpy in places, still this is how we feel about
  459. things, so there ;-)
  460.  
  461.  
  462. Intended use
  463. ------------
  464.  
  465. The Imploder is intended for creating extra space on your system disk
  466. while maintaining full functionality. To achieve this goal, we've tried
  467. to make the decompression process as invisible and fast as possible.
  468.  
  469. Thus the Imploder doesn't support any annoying colour flashing, and it
  470. has a high speed of decompression. On a vanilla 68000 Amiga, "explosion"
  471. speed is about 30-50 K/s, depending on the type of compressed code. Also,
  472. the explode.library is a bit faster than the explosion routines appended
  473. to stand-alone "imploded" files.
  474.  
  475. You should take this speed issue into consideration when determining which
  476. executables to implode. For floppy users, the startup times will mostly be
  477. FASTER. Users with fast harddrives however might want to limit themselves
  478. to imploding only infrequently used executables. It is therefore very
  479. useful to floppy users, yet harddrive users can also add a few megs to
  480. their bit budget.
  481.  
  482. Evidently, the optimum use of the Imploder will vary from system to system.
  483. A3000 owners for example won't even be able notice programs exploding.
  484.  
  485. Because of this, over the years, the emphasis of the Imploder's intended
  486. use has moved away from Imploding being a once in a program's life time
  487. operation, suitable e.g. when an author wants to distribute his program.
  488. Instead we now feel that every user should be able - when installing a
  489. program - to decide whether or not to implode it, and in what way.
  490.  
  491.  
  492. The user's responsibility
  493. -------------------------
  494.  
  495. So the issue here is freedom of choice. And it is responsibility of the
  496. user to apply the Imploder in a sensible fashion.
  497.  
  498. To get a feel for what I'm talking about simply look at what happened
  499. when people started distributing Power-Packed text files. Many people
  500. didn't like using the PPMore reader or simply didn't have it. This
  501. kind of thing can be utterly annoying, and the Imploder has the
  502. potential for the same kind of abuse.
  503.  
  504. We therefore recommend limiting the use of the Imploder to compressing
  505. things installed in your system. So if you must pass on a program to
  506. someone else, use the original archive. This keeps everyone happy,
  507. including the program's author.
  508.  
  509. Another point is that when receiving programs from PD sources, people
  510. should be able to easily check if programs contain file viri or other
  511. unwanted things. If an executable is imploded it'll have to be deploded
  512. before one is able to examine the code. So don't distribute compressed
  513. executables of _any_ type.
  514.  
  515. Still, there was one action we could take to encourage the kind of use
  516. we recommend;
  517. In previous versions one could select a "protect" option that prevented
  518. a program from being deplodable. The intent of this option was to protect
  519. an author's work before he distributed it. In reality people started using
  520. it to protect dirty hacks or programs containing file viri.
  521.  
  522. Evidently this is incompatible with our philosophy. Thus, the support for
  523. protecting programs has been discontinued as of version 4.0. In addition
  524. to this, the Imploder now allows decompression of any protected files
  525. left over from the past.
  526.  
  527.  
  528.  
  529. This document deals with the inner workings. If you're a tech type, and are
  530. interested in somewhat deeper lying aspects relating to how the Imploder
  531. operates, chances are you'll find it here.
  532. Subjects covered are:
  533.  
  534. - Compression
  535. - Decompression
  536. - Reversibility
  537. - The Library
  538. - Overlayed Files
  539. - Merging
  540. - ARP
  541. - The Music
  542. - The Copperlist
  543. - 68040 Cache Coherency
  544.  
  545.  
  546. ** Compression **
  547.  
  548. The Imploder (we only recently learned :-) does LZ77 like compression with a
  549. per-mode static Huffman coding step on the various parts of the skip, offset
  550. and length tuples. Due to the efficient encoding, a tuple can require less
  551. than 12 bits, and thus strings of 2 bytes length are encodable with a decent
  552. gain (given small Huffman patterns corresponding to likely circumstances).
  553.  
  554. To speed up the string searching, the turbo mode causes the accessible strings
  555. to be indexed using a hashing table. However, the fact that strings with a
  556. minimum size of two bytes are still potential candidates for compression,
  557. requires the hashing function to necessarily be rather simplistic. When the
  558. implosion algorithm processes highly redundant data, entries in the hashing
  559. table tends to get very imbalanced, causing a reduction in performance.
  560. For most types of data, notably executables, this isn't the case though.
  561.  
  562.  
  563. ** Decompression **
  564.  
  565. The goal of decompression is to reproduce the segment list of the
  566. original program. This is a linked list of data/code/bss hunks, some
  567. of which require being positioned in chip memory.
  568.  
  569. The decompression code will have to fill the data and code hunks with
  570. the decompressed data, and, if required, perform relocation of absolute
  571. references.
  572.  
  573. The Imploder lets LoadSeg allocate all target hunks (as BSS). These
  574. are at the start of the hunk list. This is followed by a hunk with
  575. the decompression code (only for non-library imploded programs),
  576. a compressed data hunk (normally about 50% of the static data size,
  577. depending on compression gain ofcourse), and a decompression buffer
  578. (only upto 17K in size).
  579. As you can see, no allocations need to be done, so the exploding
  580. process will never fail.
  581.  
  582. During decompression time, data is decompressed from the compressed data
  583. buffer into the decompression buffer until it has filled. It then empties
  584. this buffer by filling hunks and processing reloc tables.
  585. When the buffer has been emptied, the process repeats until all data has
  586. been scatter-decompressed across the target hunks.
  587.  
  588. Now you might ask, why not directly decompress to the target hunks
  589. instead of using a decompression buffer?
  590. This is because the the Imploder uses the decompressed data to
  591. decompress, and needs to be able to easily access it (for speed).
  592. Referencing data distributed across several hunks is much more
  593. cumbersome.
  594.  
  595. An added bonus of having separate source and target memory regions is that
  596. a notation can be used that doesn't gain under rare circumstances, but on
  597. average yields better results (No chance of source/target pointer
  598. collision).
  599.  
  600. When explosion has finished, the decompression buffer, code and data
  601. hunks are freed, and memory usage reduced to what it would have been
  602. for a non-imploded version of the program.
  603.  
  604. People often compare the Imploder to the Power Packer. The Imploder
  605. decompresses faster and looks cooler [:-)], but the most interesting
  606. differences lie in the implementation of the various steps of the
  607. decompression proccess. So let's contrast the advantages of the
  608. Imploder's approach with the Power-Packer's implementation.
  609.  
  610. - By having LoadSeg allocate all memory as BBS hunks, explosion will
  611.   never fail.
  612.   The Power-Packer on the other hand allocates hunks. If it fails it
  613.   will simply exit. Power Packed programs launched from the WorkBench
  614.   thus won't reply the startup message, which will be left dangling in
  615.   memory forever.
  616.  
  617. - Memory doesn't get fragmented. The explosion related hunks are at
  618.   the end of the seglist and thus were allocated (by LoadSeg) AFTER
  619.   the target hunks.
  620.   This isn't true for the Power-Packer. It does leave a hole in your
  621.   free memory list when it frees its decompression stuff.
  622.  
  623. - Additional memory usage is only about 50% of the static data size +
  624.   the size of the decompression buffer, which is always small relative
  625.   to large programs (maximum 17k).
  626.   So a 30K program might require 62K to decompress (30+15+17), a 300K
  627.   program will require 467K (300+150+17), assuming a 50% compression
  628.   reduction.
  629.   The memory usage report generated after a program has been imploded
  630.   includes BSS hunks. I've discussed only static data here. BSS hunks
  631.   don't require any extra memory usage of course.
  632.   Power-Packed files require a buffer as large as the original program
  633.   for both compressed data storage and decompression. Memory usage is
  634.   therefore always about twice the static data size (again ignoring BSS)
  635.   while for the Imploder it drops to 1.5 for executables large enough to
  636.   matter memory wise.
  637.  
  638. (In this comparison I'm talking about executables as produced
  639.  by Power-Packer version 3.0b.)
  640.  
  641. Non-library imploded programs have a small first hunk that calls the
  642. decompression code hunk at the end, and frees these last three hunks. 
  643. For library imploded programs this freeing occurs in the library, so no
  644. preceding hunk is needed.
  645.  
  646.  
  647. ** Reversibility **
  648.  
  649. Before compression the Imploder preprocesses executables. It kicks out all
  650. the redundant stuff by merging subreloc tables referring to the same hunk,
  651. sorting relocs (improves compression), removing debug symbols etc. etc.
  652. This is what all those info blurbs in the text window are about.
  653.  
  654. So the deploded executable isn't guaranteed to be byte by byte identical
  655. as far as loadfile control codes are concerned.
  656.  
  657. What is guaranteed is that the memory images created when the original,
  658. imploded and deploded program versions are loaded are identical.
  659.  
  660. So the deplosion process isn't 100% reversible. Normally this is no
  661. problem. The reason for uncrunching is mostly wanting to recompress
  662. an executable using a different compression mode, or having a quick
  663. peek at the code e.g. when applying a patch with something like
  664. NewZap.
  665. If however you expect to need the debug symbols, or (important)
  666. require the executable to be in the _exact_ original format in order
  667. to have things like lpatch updates to applied, you're out of luck
  668. if you've only got the compressed executable. So always keep the
  669. original archives/disks!
  670.  
  671. This is yet another argument for retaining the original archives.
  672. The Imploder is an online space creator not a distribution
  673. archiver (See the "Philosophy" text).
  674.  
  675.  
  676. ** The Library **
  677.  
  678. The library code has been unrolled a bit, and optimized here and there
  679. in order to achieve optimal performance. This makes it faster than the
  680. normal explosion algorithm.
  681.  
  682. If you library implode a program there is NO way in which the program,
  683. after explosion, will be able to notice. If you make sure the library
  684. is resident, this is also true for any executable file loaded for any
  685. purpose by any program.
  686.  
  687. For normal etc. imploded programs the startup/cleanup hunk mentioned
  688. at the end of the "decompression" section might be detected if a program
  689. goes through contortions involving finding the segment list via murky
  690. DOS structures instead of simply doing PC relative hunk start referencing
  691. which also works from the WorkBench.
  692. I haven't encountered any programs that do this. Still this is yet another
  693. reason to use the library; there is not even the slightest chance of it
  694. being incompatible with an executable.
  695.  
  696. Note that the Loadseg vector is patched in an "intelligent" manner; it
  697. will install fine for pre 2.0 kickstarts (braindead jumptable format)
  698. as well as in BCPL free systems (2.0+)
  699.  
  700. Under pre 2.0, when a library imploded file is run from the WorkBench, and
  701. the explode.library isn't resident yet, Exec will try to load the library
  702. from disk. The process's message port however is in use by the WorkBench
  703. reply message, and until it has been replied, it cannot be used by the
  704. DOS in order to send packets. Thus the DOS gurus.
  705.  
  706. Also, BCPL code doesn't jump through the the library vector. The only
  707. structural problem with this are handlers. These are loaded by the DOS,
  708. and the DOS is BCPL code, again ONLY under < 2.0. Under 2.0 the library
  709. works just like intended when it was first conceived. Transparently that
  710. is.
  711.  
  712.  
  713. ** Overlayed Files **
  714.  
  715. The Imploder compresses the load part of an overlayed file as if it were a
  716. normal executable file. Subsequently, the overlay table and the overlayed
  717. program section are appended.
  718. It then tries to adapt the overlay table. Because different types of
  719. overlay supervisors are in use, the format of the overlay table isn't
  720. known to the Imploder. The only assumption made is that the overlay table
  721. contains seek-offset longwords, at longword aligned locations, that point
  722. into the file to the hunk_header ($3F3) identifiers of the overlayed
  723. program sections.
  724. This is how the standard overlay manager operates, but nothing prevents
  725. a programmer with sufficient technical knowledge to create a novel overlay
  726. format (e.g. selfextracting DImp files).
  727.  
  728. If the Imploder finds one of these offsets, it is adjusted by the amount
  729. the initial load part of the executable file has compressed.
  730. The deplosion algorithm also tries to find these offsets when restoring the
  731. overlay table. Thus there is always a very small chance that the imploder
  732. will adapt a longword that was never meant to be an offset.
  733.  
  734. An overlayed file gets its information from the loader in four longwords,
  735. at the start of the first hunk. In an imploded overlayed file, this hunk is
  736. the root hunk, and after decrunching these longwords are adjusted and moved
  737. into the first hunk of the actual program (the second hunk of the seglist).
  738.  
  739. Evidently this process can never be 100% deterministic, so take heed and
  740. test any overlayed programs you've Imploded. Or don't use overlay implosion
  741. at all if you can spare the bits.
  742.  
  743.  
  744. ** Merging **
  745.  
  746. Though modern linkers/compilers typically produce executables with one code
  747. hunk and one data hunk, there are still some old executables and less evolved
  748. linkers around. The merging option was implemented when executables with
  749. sufficient hunks to cause a lot of redundancy were still commonplace.
  750.  
  751. Every hunk requires a longword in the allocation header, plus a hunk ID,
  752. load size, and hunk end ID. That's 16 bytes per hunk, and thus saved for
  753. every merge action. Doesn't sound like much, but generally hunks also
  754. have reloc tables. These waste a lot more space, especially with references
  755. to a lot of different hunks, though there's no easy equation.
  756.  
  757. The merging step merges matching hunks (data-data, chipdata-chipdata,
  758. code-code) into hunks of upto the merge threshold in size. The actual
  759. size is of course determined by the sum of the sizes of the composite hunks,
  760. and may very well be a bit less than the specified threshold.
  761.  
  762. Obviously this process discards redundant data in an irreversible fashion,
  763. so deploding the executable won't reverse it.
  764.  
  765. Lots of tiny hunks cause memory fragmentation, but increase the chance of
  766. the program being able to load when the system is fragmented, and low on
  767. memory. Thus there is a kind of optimal balance that varies from system
  768. to system. In general it can be said that hunks less than 10K or more than
  769. 100K are "bad".
  770.  
  771. Another factor is that loading a program with many tiny hunks causes the
  772. LoadSeg function to issue double as many tiny read commands, thus bogging
  773. down the speed with which an executable can be loaded into memory.
  774.  
  775. For simplicity's sake, I've chosen for the Imploder to process executables
  776. within a single buffer, without the need for additional backup buffers.
  777. Thus, removing redundant information, and copying hunk data during the
  778. merging and reloc cleanup process involves moving or mirroring large parts
  779. of the buffer. This is why merging can take a while when processing a large
  780. executable with a hundred or so hunks.
  781.  
  782.  
  783. ** ARP **
  784.  
  785. Programs written for use with the ARP shell are able to specify the
  786. stacksize they require inside the first hunk of their executable. If
  787. such a program is normal or pure imploded, the segment list won't become
  788. visible until the program is run. Thus ARP has no way of finding out what
  789. the proper stacksize should be.
  790. Library imploded programs have no trouble with this because they are
  791. already decrunched after they are loaded into memory with LoadSeg.
  792. (Provided the library has already been made resident.)
  793.  
  794. The Imploder will recognize these files and report on them. If the
  795. requested stack-size is larger than the usual minimum (4000 bytes)
  796. a warning will be printed, and you'll be urged to use only library
  797. implosion.
  798.  
  799. The chance of a programmer relying on a soon to be obsolete shell for
  800. setting a stack LARGER than the usual default is rather slim though.
  801. It would have been very nice if 2.0 had sported such a stack setting
  802. feature, and indeed it had been planned, but was never implemented due
  803. to lack of time on the part of the Commodore programmers.
  804.  
  805. We'll be on the lookout for any future changes to the executable file
  806. format in order to fix any potential incompatibilities before they'll
  807. cause problems.
  808.  
  809.  
  810. ** The Music **
  811.  
  812. When we got word the CIA-A timer was used by the OS under 2.0, we switched to
  813. trying to allocate first CIA-A and if not available CIA-B to drive the music.
  814. However the CIA-B interrupt priority is too high and can interfere with things
  815. like serial transfer. So Paul got this great idea to keep on using a CIA for
  816. precision timing purposes, but drop down to a SoftInt for doing the actual
  817. work, modulations, etc. This works great, the amount of code executed under
  818. CIA priority is now negligible.
  819. Recently, the CATS started feeling guilty about hijacking the CIA-A timer and
  820. thus created "Jumpy the magic timer device". If I understood things correctly
  821. the latest 2.0 timer device moves out of the way and starts using a less
  822. accurate timing source whenever an application tries to allocate the CIA-A.
  823. Pauls music driver can run of both CIA-A and CIA-B, and it would be a pity
  824. to make Jumpy jump without good reason, so he changed the alloction sequence
  825. from A-B to B-A.
  826.  
  827.  
  828. ** The Copperlist **
  829.  
  830. There are a couple of unavoidable quirks when one uses copperlists on Intuition
  831. screens. On certain machines, probably PAL, under certain circumstances, dragging
  832. a dense copperlist past scanline 256 or so will cause some video crud to appear
  833. at the top of the display. This can't hurt, but it sure does look ugly. I suspect
  834. this is a hardware misfeature because it ain't fixed yet under 2.0
  835. This was the reason why the screen of older Imploder versions wasn't draggable;
  836. you might just think this muck was our doing.
  837.  
  838. Second problem is that copperlists "shine through" onto other screens in front.
  839. For this reason we've choosen a colour > 4 for the level bars, so this is never
  840. observable with screens less than 3 bitplanes deep.
  841. The 2.0 OS support proper copperlist clipping, but it has been disabled by
  842. default for compatibility reasons (yeach). Supposedly there is a bit somewhere
  843. in the graphics base to turn this back on, so I'm sure, in due time, there will
  844. be some preference editor to re-enable this.
  845.  
  846.  
  847. ** 68040 Cache Coherency **
  848.  
  849. With the advent of the 68040 processor, programs that diddle with code which is
  850. subsequently executed will be prone to some problems. I don't mean the usual
  851. self-modifying code causing the code cached in the data cache to no longer
  852. be as the algorithm expects. This is something the Imploder never had a
  853. problem with, indeed the Imploder has always worked fine with anything
  854. upto and including an 68030.
  855.  
  856. The reason the 68040 is different is that it has a "copyback" mode. In this
  857. mode (which WILL be used by people because it increases speed dramatically)
  858. writes get cached and aren't guaranteed to be written out to main memory
  859. immediately. Thus 4 subsequent byte writes will require only one longword
  860. main memory write access. Now you might have heard that the 68040 does
  861. bus-snooping. The odd thing is that it doesn't snoop the internal cache
  862. buses!
  863.  
  864. Thus if you stuff some code into memory and try to execute it, chances are
  865. some of it will still be in the data cache. The code cache won't know about
  866. this and won't be notified when it caches from main memory those locations
  867. which do not yet contain code still to be written out from the data caches.
  868. This problem is amplified by the absolutely huge size of the caches.
  869.  
  870. So programs that move code, like the explosion algorithms, need to do a
  871. cache flush after being done. As of version 4.0, the appended decompression
  872. algorithms as well as the explode.library flush the cache, but only onder OS
  873. 2.0. The reason for this is that only OS 2.0 has calls for cache-flushing.
  874.  
  875. This is yet another reason not to distribute imploded programs; they might
  876. just cross the path of a proud '40 owner still running under 1.3.
  877.  
  878. It will be interesting to see how many other applications will run into
  879. trouble once the '40 comes into common use among Amiga owners. The problem
  880. explained above is something that could not have been easily anticipated
  881. by developers. It is known that the startup code shipped with certain
  882. compilers does copy bits of code, so it might very well be a large problem.
  883.  
  884.  
  885.  
  886. The Imploder was conceived, written and performed by:
  887.  
  888. Albert-Jan Brouwer    -    Programming, documentation.
  889. Peter Struijk        -    More programming, less documentation.
  890. Paul van der Valk    -    Music-programming and composition.
  891. Erwin Zwart        -    Graphics, aesthetic lay-out.
  892.  
  893.  
  894. Please direct queries, comments, bug reports, and other things that can
  895. not be resolved by rtfming to:
  896.  
  897. UUCP hp4nl.nluug.nl!cbmnlux!ecl001!ajbrouw
  898. UUCP cbmvax.commodore.com!cbmehq!cbmnlux!ecl001!ajbrouw
  899. FIDO: 2:281/614 (up for freq sometime fall '91)
  900.  
  901.  
  902. Legal mush:
  903.  
  904. The Imploder is Freely-Distributable, as opposed to Public Domain.
  905. Permission is given to freely distribute this program provided you
  906. include this documentation and other related files, and no fee is
  907. charged in excess of reasonable media and mailing costs.
  908. All programs in this distribution have been enforced and mungwalled.
  909.  
  910.  
  911. P.S.
  912.  
  913. We've been promising a 4.0 version for over a year now, well here it
  914. is. Things got delayed slightly. We apologize for the inconvenience.
  915.  
  916. End.
  917.